package com.nuc6.controller;

import com.nuc6.entity.Doscore;
import com.nuc6.entity.InterviewArrangement;
import com.nuc6.entity.Myquestion;
import com.nuc6.entity.QuestionManage;
import com.nuc6.service.DoscoreService;
import com.nuc6.service.MyquestionService;
import com.nuc6.service.QuestionManageService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author zwp
 * @version 1.0
 */
@Controller
public class HrController {
    @Resource
    private QuestionManageService questionManageService;
    @Resource
    private MyquestionService myquestionService;
    @Resource
    private DoscoreService doscoreService;
    @GetMapping("/hr")
    public String toHr(){
        return "hr";
    }
    @GetMapping("/score")
    public String toScore(){
        return "score";
    }
    @PostMapping("/score")
    public String doScore(HttpServletRequest request,
                          Model model){
        String tel = request.getParameter("tel");
        String score = request.getParameter("score");
        Doscore doscore = new Doscore(tel, score);
        doscoreService.save(doscore);
        model.addAttribute("msg", "发送成功");
        return "score";
    }
    @GetMapping("/interviewQuestionBank")
    public String toInterviewQuestionBank(HttpServletRequest request){
        List<QuestionManage> questions = questionManageService.list();
        request.setAttribute("question",questions);
        return "interviewQuestionBank";
    }

    @GetMapping("/sendTestQuestions")
    public String toSendTestQuestions(){
        return "sendTestQuestions";
    }
    @PostMapping("/sendTestQuestions")
    public String doSendTestQuestions(HttpServletRequest request,
                                      HttpSession session,
                                      Model model){
        String tel = request.getParameter("tel");
        String type = request.getParameter("type");
        Myquestion myquestion = new Myquestion(tel, type);
        myquestionService.save(myquestion);
        model.addAttribute("msg", "发送成功");

        return "sendTestQuestions";
    }
}
